home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 510 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: teal.csn.net!not-for-mail
  2. From: thads@csn.net (Thad Smith)
  3. Newsgroups: comp.std.c
  4. Subject: Bit-field sizes
  5. Date: 5 Mar 1996 23:49:35 -0700
  6. Organization: T3 Systems
  7. Message-ID: <nzRPxQ9ytZZA084yn@csn.net>
  8. Reply-To: ThadSmith@acm.org
  9. NNTP-Posting-Host: 199.117.27.22
  10.  
  11. Can the size of a bit-field, measured in bits, exceed the size of an
  12. int?  The description of bit-fields describes it as an integral
  13. type with a (programmer-)specified number of bits, not specifically
  14. constrained in size.  ANSI Classic section 3.2.1.1 says, however, that
  15. bit-fields are promoted to either int or unsigned int.  This would
  16. seem to prohibit promoting a large bit-field to a long.  If so, why
  17. was this constraint imposed?
  18.  
  19. Secondly, is the storage unit within which bit-fields are allocated
  20. constrained to be a single size or can it vary, depending on the size
  21. of the bit fields?  I see nothing in the standard prohibiting
  22. different size storage units for bit-fields.  Also bit-fields are
  23. explicitly allowed to span multiple storage units, at least if the
  24. bit-field is not the first in a structure (the use of the word "may"
  25. makes the requirement for the first bit-field ambiguous with regard to
  26. storage in a single unit).
  27.  
  28. If different size storage units are allowed or any bit-field is
  29. allowed to span multiple units, the size of a struct containing
  30. bit-fields might be 1 byte, while bit-fields could be allocated up to
  31. the size (in bits) of ints, possibly four bytes in a particular
  32. implementation, by choosing larger storage units for larger
  33. bit-fields.
  34.  
  35. Is anyone aware of an implementation using bit-field storage units
  36. smaller than int?
  37.  
  38. Thad
  39.